var req = require('../../interfaceImpl.js');
var config = require('../../interfaceConfig.js');
var app = getApp();
var pointsList = [] ;
var pageIndex =1;
var pageSize = 10;
Page({
  onLoad: function (options) {
      //TODO请求积分记录 
    this.setData({ point: app.globalData.loginuserinfo.points})
    return req.PointsList(pageIndex, pageSize,app.globalData.token).then(res=>{
        if(res.data.success){
            console.log(res)
            pointsList=res.data.data;
            this.setData({pointsList})
        }
        else{
            wx.showModal({
                title: '获取失败',
                content: res.data.data,
                showCancel: false,
                success: function (res) {
                }
              })
        }
    })
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    //TODO分页
    pageIndex++;
    return req.PointsList(pageIndex, pageSize, app.globalData.token).then(res => {
      console.log(res)
      pointsList=pointsList.concat(res.data.data);
      this.setData({ pointsList })
    })
  },
})